from typing import List


class ListNode:
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next

    def __str__(self):
        return f'val: {self.val}, next: {self.next.val}'

class DListNode:
    def __init__(self, val=0, prev=None, next=None, ):
        self.val = val
        self.prev = prev
        self.next = next

def print_list(head):
    forward = str(head.val)
    head = head.next
    while head:
        forward += ' => ' + str(head.val)
        head = head.next
    print(forward)

def generate_list(arr: List[int]) -> ListNode:
    res = ListNode()
    cur = res
    for e in arr:
        cur.next = ListNode(e)
        cur = cur.next
    return res.next